package com.liaohuakai.piggybank.remote.dto

import android.os.Parcel
import android.os.Parcelable
import android.os.Parcelable.Creator
import com.google.gson.annotations.SerializedName

/**
 * Author: Leo Liao
 * Date: 17/07/2025 15:30
 * Description:
 */
class UserLoginResponseDto constructor(`in`: Parcel) : Parcelable {
    @SerializedName("token")
    var token: String? = `in`.readString()

    @SerializedName("id")
    var id: Int = `in`.readInt()

    @SerializedName("name")
    var name: String? = `in`.readString()

    @SerializedName("email")
    var email: String? = `in`.readString()

    @SerializedName("phoneNumber")
    var phoneNumber: String? = `in`.readString()

    @SerializedName("avatarUrl")
    var avatarUrl: String? = `in`.readString()

    @SerializedName("gender")
    var gender: Int = `in`.readInt()

    @SerializedName("createDate")
    var createDate: String? = `in`.readString()

    @SerializedName("lastUpdateTime")
    var lastUpdateTime: String? = `in`.readString()

    @SerializedName("pairedGroupId")
    var pairedGroupId: Int = `in`.readInt()

    @SerializedName("role")
    var role: String? = `in`.readString()

    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(parcel: Parcel, i: Int) {
        parcel.writeString(token)
        parcel.writeInt(id)
        parcel.writeString(name)
        parcel.writeString(email)
        parcel.writeString(phoneNumber)
        parcel.writeString(avatarUrl)
        parcel.writeInt(gender)
        parcel.writeString(createDate)
        parcel.writeString(lastUpdateTime)
        parcel.writeInt(pairedGroupId)
        parcel.writeString(role)
    }

    override fun toString(): String {
        return "UserDto{" +
                "token='" + token + '\'' +
                ", id=" + id +
                ", name='" + name + '\'' +
                ", email='" + email + '\'' +
                ", phoneNumber='" + phoneNumber + '\'' +
                ", avatarUrl='" + avatarUrl + '\'' +
                ", gender=" + gender +
                ", createDate='" + createDate + '\'' +
                ", lastUpdateTime='" + lastUpdateTime + '\'' +
                ", pairedGroupId=" + pairedGroupId +
                ", role='" + role + '\'' +
                '}'
    }

    companion object {
        @JvmField
        val CREATOR: Creator<UserLoginResponseDto> = object : Creator<UserLoginResponseDto> {
            override fun createFromParcel(`in`: Parcel): UserLoginResponseDto {
                return UserLoginResponseDto(`in`)
            }

            override fun newArray(size: Int): Array<UserLoginResponseDto?> {
                return arrayOfNulls(size)
            }
        }
    }

}